<?php


namespace EchoPHP\Database\Connectors;

use EchoPHP\Database\TuxedoDriver\Tuxedo;

class TuxedoConnector extends Connector implements ConnectorInterface {

    /**
     * 连接数据库
     * @param array $config
     * @return Tuxedo|\PDO
     */
    public function connect(array $config) {
        $connection = $this->createConnection('', '', '', $config);
        return $connection;
    }

    /**
     * 创建数据库连接
     * @param $dsn
     * @param string $username
     * @param string $password
     * @param array $option
     * @return Tuxedo|\PDO
     */
    public function createConnection($dsn, string $username, string $password, array $option) {
        $server = $option['server'] ?? '';
        $dbType = $option['dbtype'] ?? '';
        $dbId = $option['dbid'] ?? 1;
        return new Tuxedo($server, $dbType, $dbId);
    }


}